﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace LevelEditor
{
    class MainMenuInteraction
    {
        public void showOpenFileDialog()
        {
            openFileDialog = new OpenFileDialog();
            openFileDialog.Filter = filter;
            openFileDialog.FilterIndex = 1;
            openFileDialog.RestoreDirectory = true;
            openFileDialog.AutoUpgradeEnabled = true;
            openFileDialog.SupportMultiDottedExtensions = true;
            openFileDialog.Title = "DevilRun Level Editor - Open File";

            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                //TODO kod czytający plik
            }
            else
            {
                MessageBox.Show("Error loading level file", DEVIL_MSG_ERROR, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }

        public void showSaveFileDialog()
        {
            saveFileDialog = new SaveFileDialog();
            saveFileDialog.Filter = filter;
            saveFileDialog.FilterIndex = 1;
            saveFileDialog.RestoreDirectory = true;
            saveFileDialog.AutoUpgradeEnabled = true;
            saveFileDialog.SupportMultiDottedExtensions = true;
            saveFileDialog.Title = "DevilRun Level Editor - Save File";
            if (saveFileDialog.ShowDialog() == DialogResult.OK)
            {
                //TODO kod zapisujący plik
            }
            else
            {
                MessageBox.Show("Error when saving file", DEVIL_MSG_ERROR, MessageBoxButtons.OK, MessageBoxIcon.Error);

            }
        }

        public void setSavingFile()
        {
            if (!State.getInstance().IsFileSaved)
            {
                MessageBox.Show("File is not saved");
            }
        }

        public void showAboutBox()
        {
            AboutBox aBox = new AboutBox();
            aBox.ShowDialog();
        }




        private OpenFileDialog openFileDialog;
        private SaveFileDialog saveFileDialog;
        private string filter = "DevilRun Level File (*.drl)|*.drl";
        private const string DEVIL_MSG_ERROR = "DevilRun Editor Error";
    }
}
